package com.xbongbong.paas.factory;

import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.help.symbol.AbstractSymbolHandle;
import com.xbongbong.paas.help.symbol.AddTimeSymbolHandle;
import com.xbongbong.paas.help.symbol.AddressSymbolHandle;
import com.xbongbong.paas.help.symbol.ComboCheckSymbolHandle;
import com.xbongbong.paas.help.symbol.ComboSymbolHandle;
import com.xbongbong.paas.help.symbol.CreatorIdSymbolHandle;
import com.xbongbong.paas.help.symbol.DateTimeSymbolHandle;
import com.xbongbong.paas.help.symbol.DepartmentIdSymbolHandle;
import com.xbongbong.paas.help.symbol.LinkBusinessSingleSymbolHandle;
import com.xbongbong.paas.help.symbol.NumSymbolHandle;
import com.xbongbong.paas.help.symbol.SerialNoSymbolHandle;
import com.xbongbong.paas.help.symbol.TextSymbolHandle;
import com.xbongbong.paas.help.symbol.UpdateTimeSymbolHandle;
import com.xbongbong.paas.help.symbol.UserAndDeptGroupSymbolHandle;
import com.xbongbong.paas.help.symbol.VideoSymbolHandle;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.enums.errorcodes.ThirdPartyUsageErrorCodeEnum;

/**
 * @author 吴峰
 * @date 2021/01/07 14:21
 */
public class SymbolFactory {

    /**
     * 业务规则逻辑运算
     * @param fieldType
     * @return
     */
    public static AbstractSymbolHandle getSymbolByFieldType(Integer fieldType) throws XbbException {
        FieldTypeEnum fieldTypeEnum = FieldTypeEnum.getFieldTypeEnum(fieldType);
        switch (fieldTypeEnum) {
            case TEXT:
            case TEXTAREA:
            case DEPT:
            case USER:
            case MANUAL_SIGN:
                return new TextSymbolHandle();
            case CREATORID:
                return new CreatorIdSymbolHandle();
            case COMBO:
            case RADIO_GROUP:
            case STAGE_THRUSTER:
                return new ComboSymbolHandle();
            case COMBO_CHECK:
            case CHECKBOX_GROUP:
                return new ComboCheckSymbolHandle();
            case SERIALNO:
                return new SerialNoSymbolHandle();
            case ADDRESS:
                return new AddressSymbolHandle();
            case NUM:
            case STAR:
                return new NumSymbolHandle();
            case USER_GROUP:
            case DEPT_GROUP:
                return new UserAndDeptGroupSymbolHandle();
            case DEPARTMENTID:
                return new DepartmentIdSymbolHandle();
            case DATETIME:
                return new DateTimeSymbolHandle();
            case ADDTIME:
                return new AddTimeSymbolHandle();
            case UPDATETIME:
                return new UpdateTimeSymbolHandle();
            case LINK_BUSINESS_SINGLE:
                return new LinkBusinessSingleSymbolHandle();
            case VIDEO:
                return new VideoSymbolHandle();
            default:
                throw new XbbException(ThirdPartyUsageErrorCodeEnum.API_ERROR_900005, String.format(ThirdPartyUsageErrorCodeEnum.API_ERROR_900005.getMsg(), "条件逻辑符号"));
        }
    }
}
